<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>函数式组件使用props</title>
</head>
<body>
  <div id="test"></div>

  <!-- 引入库：先引入核心库，再引入操作DOM的扩展库 -->
  <script type="text/javascript" src="../js/react.development.js"></script>
  <script type="text/javascript" src="../js/react-dom.development.js"></script>
  <!-- 将jsx转为js -->
  <script type="text/javascript" src="../js/babel.min.js"></script>
  <!-- 引入prop-types，用于对组件标签属性进行限制 -->
   <script type="text/javascript" src="../js/prop-types.js"></script>

  <script type="text/babel">    //必须写babel，因为默认js

    function Person(props){
      const {name,age,sex} = props
      return (
        <ul>
          <li>姓名：{name}</li>
          <li>年龄：{age}</li>
          <li>性别：{sex}</li>
        </ul>
      )
    }

    Person.propTypes = {
      name:PropTypes.string.isRequires,
      sex:PropTypes.string,
      age:PropTypes.number
    }
    Person.defaultProps = {
      sex:'不男不女',
      age:18
    }

    ReactDOM.render(<Person name='zhang'/>, document.getElementById('test'))
  </script>
</body>
</html>